package com.lingnan.blog.mapper;

import com.lingnan.blog.entity.ArticleTag;
import org.apache.ibatis.annotations.*;

/**
 * @author HeGuanChao
 */
@Mapper
public interface ArticleTagMapper {
    int insertSelective(ArticleTag articleTag);

    ArticleTag selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(ArticleTag articleTag);

    int updateByPrimaryKey(ArticleTag articleTag);

    /**
     * 根据文章id查询文章标签(一对多)
     *
     * @param aid
     * @return ArticleTags
     */
    @Select("select * from article_tag where a_id = #{aid} ")
    @Results({
            @Result(id = true, column = "id", property = "id"),
            @Result(column = "a_id", property = "aId"),
            @Result(column = "t_id", property = "tId"),
            @Result(column = "t_id", property = "tag",
                    one = @One(select = "com.lingnan.blog.mapper.TagMapper.selectById"))
    })
    ArticleTag selectByAid(Integer aid);
}